/**
 * 
 */
package org.sishoras.logic;

import java.util.List;

import org.sishoras.dao.DAOFactory;
import org.sishoras.interceptors.DAOInterceptor;
import org.sishoras.modelo.Curso;
import org.sishoras.modelo.Turma;
import org.vraptor.annotations.Component;
import org.vraptor.annotations.InterceptedBy;

/**
 * This class is part of the SisHoras project	
 * Creation:  30/12/2008 20:33:02
 * TODO
 * 
 * @author Walker Rabelo
 * 
 */
@Component
@InterceptedBy(DAOInterceptor.class)
public class TurmaLogic {

	private final DAOFactory daoFactory;
	
	private Turma turma;	
	private List<Turma> turmas;
	
	public TurmaLogic(DAOFactory factory) {
		// TODO Auto-generated constructor stub
		this.daoFactory = factory;
	}
	public void form(){
		
	}	
	public void editar(Turma turma){
		this.turma = this.daoFactory.getTurmaDao().carregar(turma.getId());
	}	
	public void armazena(Turma turma){
		this.daoFactory.beginTransaction();
		this.daoFactory.getTurmaDao().atualiza(turma);
		this.daoFactory.commit();
	}
	public void remove(Turma turma){
		this.daoFactory.beginTransaction();
		this.daoFactory.getTurmaDao().remover(turma);
		this.daoFactory.commit();
	}
	public void lista(){
		turmas = this.daoFactory.getTurmaDao().getLista();
	}

	/**
	 * @return the turmas
	 */
	public List<Turma> getTurmas() {
		return turmas;
	}
	
	/**
	 * @return the cursos
	 */
	public List<Curso> getListaCursos() {
		return this.daoFactory.getCursoDao().getLista();
	}
	public Turma getTurma() {
		return turma;
	}
}
